gh-153569: return token spans and unify decoded source storage - #156482
Open
pablogsal wants to merge 6 commits into
Open
gh-153569: return token spans and unify decoded source storage#156482pablogsal wants to merge 6 commits into
pablogsal wants to merge 6 commits into
Conversation
Member
Author
|
Do not review until #156472 lands. |
pablogsal
force-pushed
the
gh-153569-tokenizer-offset-state
branch
from
August 28, 2026 15:32
dddc133 to
1753605
Compare
Member
Author
|
#156472 has landed; this is rebased on it now. |
pablogsal
force-pushed
the
gh-153569-tokenizer-offset-state
branch
from
August 28, 2026 16:24
1753605 to
8bd1d3a
Compare
pablogsal
force-pushed
the
gh-153569-tokenizer-offset-state
branch
from
August 28, 2026 18:08
8bd1d3a to
c10fd82
Compare
pablogsal
marked this pull request as ready for review
August 28, 2026 21:15
pablogsal
force-pushed
the
gh-153569-tokenizer-offset-state
branch
3 times, most recently
from
August 30, 2026 16:10
150ee6a to
f134e81
Compare
File and readline tokenizers keep every byte they read because the lexer owns buffer growth and repairs its pointers after reallocations. Long inputs therefore grow tokenizer memory with the entire source. Let the reader reuse a bounded input window when no token or formatted string needs older bytes. Track the absolute offset of that window and save pointer offsets only when backing storage moves.
Tokenizer results expose pointers into the active input buffer. That ties every consumer to the buffer lifetime and prevents the reader from reusing older storage. Return logical source spans with their start and end locations instead. Pegen and `_tokenize` materialize a short-lived view before requesting another token, and the tokenizer no longer keeps a second end pointer for the last token.
pablogsal
force-pushed
the
gh-153569-tokenizer-offset-state
branch
from
September 5, 2026 19:52
bf25f7b to
6117ae3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Return tokenizer tokens as logical source spans with start/end locations, and give all decoded input one owner in SourceText.
File and readline input discard consumed windows while advancing a logical base offset. Discard reuses the allocation and resets line metadata; prepared and interactive input retain their source. The separate streaming buffer allocation is removed. This prerequisite still rebases scanner pointers around append; #156654 replaces those pointers with offsets.
Debug source growth forces relocation. Tests cover f-/t-string growth in both token modes, interactive multiline input, discard/reuse, implicit-line metadata reset, and offset limits.
This follows #156472. The rest of the stack is #156484, then #156654.
Validation on current main: the full debug suite ran 52,011 tests. Only perf-profiler tests failed during simultaneous runs with shared perf mapping-resource errors; all 14 profiler tests passed in the sequential rerun. Patchcheck and Windows project/source checks passed.